package com.gitee.slowcreator.http.file.download.hutool;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.gitee.slowcreator.http.file.download.template.AbstractLocalFileDownload;

import java.io.InputStream;

/**
 * @author zxw
 * @date 2023/6/11 15:16
 */
public class HutoolLocalFileDownload extends AbstractLocalFileDownload<HttpRequest, HttpResponse> {

    @Override
    protected String getContentDisposition(HttpRequest request, HttpResponse response) {
        return response.header("Content-Disposition");
    }

    @Override
    protected String getContentType(HttpRequest request, HttpResponse response) {
        return request.header("Content-Type");
    }

    @Override
    protected InputStream getDownloadInputStream(HttpRequest request, HttpResponse response) {
        return response.bodyStream();
    }

    @Override
    protected long getFileLength(HttpRequest request, HttpResponse response) {
        return response.contentLength();
    }

    @Override
    protected String getRequestUrl(HttpRequest request, HttpResponse response) {
        return request.getUrl();
    }
}
